package edu.bbu.commonproject.desktop.gui.view.swing.login;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import edu.bbu.commonproject.desktop.gui.view.swing.utils.Design;

/**
 * The register panel class.
 */
public class RegisterPanel extends JPanel
{
	/** The base image. */
	private Image baseImage;

	/** User name label. */
	private JLabel userNameLabel;
	
	/** User name textfield. */
	private JTextField userNameTextField;
	
	/** User name confirmation label. */
	private JLabel userNameConfirmationLabel;
	
	/** The user name confirmation textfield. */
	private JTextField userNameConfirmationTextField;
	
	/** The register user button. */
	private JButton registerUserButton;
	
	/** The error label. */
	private JLabel errorLabel;
	
	/**
	 * The constructor.
	 */
	public RegisterPanel()
	{
		baseImage = Design.COMPONENT_REGISTER;
		this.setSize(new Dimension(600, 400));
		this.setLayout(null);
		
		setComponents();
		
	}
	
	/**
	 * Sets up the components and adds it to the panels.
	 */
	public void setComponents()
	{
		userNameLabel = new JLabel("Email adress");
		userNameLabel.setSize(new Dimension(110,30));
		userNameLabel.setLocation(100, 124);
		userNameLabel.setForeground(Color.WHITE);
		userNameLabel.setFont(new Font("SansSerif", Font.BOLD, 12));
		
		userNameTextField = new JTextField();
		userNameTextField.setSize(new Dimension(280,30));
		userNameTextField.setLocation(215, 125);
		
		userNameConfirmationLabel = new JLabel("Conf. e-mail adress");
		userNameConfirmationLabel.setSize(new Dimension(110,30));
		userNameConfirmationLabel.setLocation(100, 159);
		userNameConfirmationLabel.setForeground(Color.WHITE);
		userNameConfirmationLabel.setFont(new Font("SansSerif", Font.BOLD, 12));
		
		userNameConfirmationTextField = new JTextField();
		userNameConfirmationTextField.setSize(new Dimension(280,30));
		userNameConfirmationTextField.setLocation(215, 160);
		
		registerUserButton = new JButton("Register");
		registerUserButton.setSize(new Dimension(145,40));
		registerUserButton.setLocation(350, 210);
		
		errorLabel = new JLabel("The e-mail adress already exists.");
		errorLabel.setSize(new Dimension(200,40));
		errorLabel.setLocation(295, 265);
		errorLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		errorLabel.setForeground(Color.ORANGE);
		errorLabel.setFont(new Font("SansSerif", Font.BOLD, 12));
		errorLabel.setVisible(false);
		
		this.add(userNameLabel);
		this.add(userNameTextField);
		this.add(userNameConfirmationLabel);
		this.add(userNameConfirmationTextField);
		this.add(registerUserButton);
		this.add(errorLabel);
	}
	
	/**
	 * Gets the username textfield.
	 * @return the username textfield.
	 */
	public JTextField getUserNameTextField()
	{
		return userNameTextField;
	}

	/**
	 * Gets the username confirmation text field.
	 * @return the username confirmation text field.
	 */
	public JTextField getConfirmUsernameTextField()
	{
		return userNameConfirmationTextField;
	}

	/**
	 * Gets the register button.
	 * @return the register button.
	 */
	public JButton getRegisterButton()
	{
		return registerUserButton;
	}
	
	/**
	 * Gets the error label.
	 * @return the error label.
	 */
	public JLabel getErrorLabel()
	{
		return errorLabel;
	}
	
	/**
	 * The overrided paintComponent.
	 */
	protected void paintComponent(Graphics g)
	{
		g.drawImage(baseImage, 0, 0, null);
	}
}
